﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary.Generator
{
    /// <summary>
    /// This class provides a function generator for the real incomplete Gammafunction.
    /// </summary>
    [Serializable]
    public class IncompleteGammaFunctionGenerator : AbstractOneParameterFunctionGenerator
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="IncompleteGammaFunctionGenerator"/> class.
        /// </summary>
        /// <param name="interval">The interval of the function generator.</param>
        public IncompleteGammaFunctionGenerator(double interval)
            : base(interval)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="IncompleteGammaFunctionGenerator"/> class.
        /// </summary>
        /// <param name="interval">The interval of the function generator.</param>
        /// <param name="startvalue">The start value of the function generator.</param>
        public IncompleteGammaFunctionGenerator(double interval, double startvalue)
            : base(interval, startvalue)
        {
        }

        /// <summary>
        /// Calculates the next value by using the incomplete Gamma function.
        /// </summary>
        /// <returns>The calculated value of the generator.</returns>
        public override double NextValue()
        {
            double result = SpecialFunctions.LogGammaFunction(this.currentValue);

            this.currentValue += this.Interval;

            return result;
        }
    }
}